package com.ljq.serviceverificationcode.service.impl;


import com.ljq.intemalcommon.dto.ResponseResult;
import com.ljq.intemalcommon.responese.NumberCodeResponse;
import com.ljq.serviceverificationcode.service.VerificodeCationService;
import org.springframework.stereotype.Service;

import java.util.Random;

@Service
public class VerificodeCationServiceImpl implements VerificodeCationService {

    @Override
    public ResponseResult numberCode(Integer size) {

        Random random = new Random();
        StringBuilder code;
        code = new StringBuilder();
        int a = size;
        while (a-->0){
            code.append(random.nextInt(10));
        }

        NumberCodeResponse numberCodeResponese = new NumberCodeResponse();
        numberCodeResponese.setNumberCode(String.valueOf(code));

        return ResponseResult.success(numberCodeResponese);
    }
}
